<?php
include_once('class/autoload.php'); // pour inclure nos classes
include_once('class/config.inc.php');
$site = new page_securisee('accueil');
if (utilCoTypeC($_SESSION['identifiant']) == 1){
if(!empty($_POST['nomNouvCab'])&&!empty($_POST['TelNouvCab'])&&!empty($_POST['Nvoie'])&&!empty($_POST['Lvoie'])&&!empty($_POST['CP'])&&!empty($_POST['Ville'])){
	if(AjoutCab($_POST['nomNouvCab'],$_POST['TelNouvCab'],$_POST['Nvoie'],$_POST['Lvoie'],$_POST['CP'],$_POST['Ville'], $_POST['Pays'])){
		$site->corps = '<script>bootbox.alert("Cabinet Enregistré.");</script>';
	}
	else{
		$site->corps = '<script>bootbox.alert("Erreur rééssayer : Cabinet déjà enregistré ou adresse non valide.");</script>';
	}
}
$site->corps .= 
'<form method="post"  action="AjoutCabinet.php">
        <h2 class="form-signin-heading">Ajouter un cabinet</h2>
		<div class="form-inline form-group">
        <input type="text" class="form-control" placeholder="Nom" id="nomNouvPrat" name="nomNouvCab">
		<input type="text" class="form-control" placeholder="Téléphone" id="prenomNouvPrat" name="TelNouvCab" pattern="^((\+\d{1,3}(-| )?\(?\d\)?(-| )?\d{1,5})|(\(?\d{2,6}\)?))(-| )?(\d{3,4})(-| )?(\d{4})(( x| ext)\d{1,5}){0,1}$" required>
		</div>
		<div class="form-inline form-group">
			<input type="text" class="form-control" placeholder="N° voie" id="Nvoie" name="Nvoie">
			<input type="text" class="form-control" placeholder="Libelle voie" id="Lvoie" name="Lvoie">
			<input type="text" class="form-control" placeholder="Code Postal" id="CP" name="CP">
			<input type="text" class="form-control" placeholder="Ville" id="Ville" name="Ville">
			<input type="text" class="form-control" placeholder="Pays" id="Ville" name="Pays">
		</div><br/>
        <input class="btn btn-large btn-success submit" type="button" value="Ajouter le cabinet">
</form>'.jsAjoutCab();
}
else{
	$site->corps = 'Vous ne pouvez pas acc&eacuteder &agrave cette page.';
}
$site->affiche();
?>